<?php

!defined('IN_SYSTEM') && exit('Access denied');

function showtableheader($class='',$id='',$extra='') {
    $html = '';
    if ($class) {
        $html .= " class='{$class}'";
    }
    if ($id) {
        $html .= " id='{$id}'";
    }
    if ($extra) {
        $html .= " ".$extra;
    }
    return "<table{$html}><tbody>";
}

function showtablefooter() {
    return '</tboby></table>';
}

function showtablerowth($array,$trextra='') {
    $trextra = $trextra ? " ".$trextra : '';
    $html = "<tr{$trextra}>";
    $html .= showtablerowfetch($array,'th');
    $html .= "</tr>";

    return $html;
}

function showtablerowtd($array,$trextra='') {
    $trextra = $trextra ? " ".$trextra : '';
    $html = "<tr{$trextra}>";
    $html .= showtablerowfetch($array,'td');
    $html .= "</tr>";

    return $html;
}

function showtablerowfetch($array,$t='td') {
    $html = '';
    foreach ((array)$array as $item) {
        if (is_array($item)) {
            $html .= "<{$t}".($item['1'] ? ' '.$item['1'] : '').">{$item['0']}</{$t}>";
        } else {
            $html .= "<{$t}>{$item}</{$t}>";
        }
    }
    return $html;
}